<template>
  <a-form>
    <a-row :gutter="24">
      <a-col :lg="6" :md="12" :sm="24" style="float:right">
        <div :style="{ float: 'right', overflow: 'hidden', margin: '10px 0' }">
          <a-button v-if="displayf != 'choose'" @click="add" style="margin-left: 14px;">添加</a-button>
          <!-- <a-button v-if="displayf != 'choose'" style="margin-left: 14px;" @click="importExcel(queryParam)">导入</a-button> -->
          <!-- <a-button v-if="displayf != 'choose'" style="margin-left: 14px;" @click="exportExcel(queryParam)">导出</a-button> -->
          <a-popconfirm v-if="displayf != 'choose'" title="确定删除?" okText="确定" cancelText="取消" @confirm="deleted">
            <a-button type="danger" style="margin-left: 14px;">删除</a-button>
          </a-popconfirm>
          <a-button v-if="displayf == 'choose'" style="margin-left: 14px;" @click="enSure()">确定</a-button>
        </div>
      </a-col>
    </a-row>
  </a-form>
</template>

<script>
import { dropList } from '@/api/drop'
import dropValue from '@/views/dropValue'
import moment from 'moment'
import { authDevice } from '@/utils/mixin'
export default {
  name: 'SearchFom',
  components: {},
  props: {
    displayf: {
      type: String,
      required: false
    },
    type: {
      type: String,
      required: false
    }
  },
  data() {
    return {
      a: process.env.VUE_APP_API_BASE_URL + '/api/students/ImportExcel',
      fileList: [],
      queryParam: {
        code: null,
        name: null,
        iDNumber: null,
        sex: null,
        consultationTimeStart: null,
        consultationTimeEnd: null
      },
      belongBank: [],
      formItemLayout: {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 18 }
        }
      },
      formItemLayout1: {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 10 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 14 }
        }
      }
    }
  },
  watch: {},
  computed: {},
  methods: {
    moment,
    clearData() {
      Object.assign(this.queryParam, {
        name: null,
        oldAddress: null,
        iDNumber: null
      })
    },
    add() {
      this.$emit('handleAdd')
    },
    deleted() {
      this.$emit('handleDel')
    },
    enSure() {
      this.$emit('handleEnSure')
    },
    onChangeDate(dates, dateStrings) {
      this.startDate = dateStrings[0]
      this.endDate = dateStrings[1]
      this.queryParam.consultationTimeStart = dateStrings[0]
      this.queryParam.consultationTimeEnd = dateStrings[1]
    },
    onSearch(data) {
      const objData = { ...data }
      objData.isRetire = objData.isRetire == 1 ? true : objData.isRetire == 0 ? false : null
      this.$emit('search', objData)
    },
    exportExcel(data) {
      const objData = { ...data }
      this.$emit('exportXls', objData)
    },
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    download() {},
    beforeUpload(file) {
      this.a = process.env.VUE_APP_API_BASE_URL + '/api/students/ImportExcel'
      const isJpgOrPng = file.type === 'application/vnd.ms-excel' || file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      if (!isJpgOrPng) {
        this.$message.error('您只能上传Excel文件!')
      }
    },
    handleChange(info) {
      const file = info.file
      const isJpgOrPng = file.type === 'application/vnd.ms-excel' || file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      if (isJpgOrPng) {
        let fileList = [...info.fileList]
        this.fileList = fileList
        // if (file.response) {
        //   if (info.file.status === 'done') {
        //     this.$message.info(file.response)
        //     this.fileList = []
        //   }
        // }
        if (info.file.status === 'done') {
          if (file.response) {
            this.$message.info(file.response)
            this.fileList = []
          }
        }
      }
    }
  },
  created() {},
  mounted() {}
}
</script>
<style lang="less" scoped>
.ant-form-item {
  margin-bottom: 0;
}
</style>
